package thread;


public class ThreadExample {
    public static void main(String[] args) {
        // 创建两个线程对象
        MyThread thread1 = new MyThread("线程1");
        MyThread thread2 = new MyThread("线程2");

        // 启动线程
        thread1.start();
        thread2.start();

        try {
            // 等待两个线程都结束
            thread1.join();
            thread2.join();
        } catch (InterruptedException e) {
            System.out.println("主线程被中断");
        }

        System.out.println("主线程退出");
    }
}